import Vue from "vue";
import Router from "vue-router";
import { getToken } from "@/utils/auth.js";
import { helpType } from "@/wss/utils/wss.js";
// import { getConsultTypeListApi } from "@/wss/newApi_3-24/work/consultType.js";
import axios from "axios";
Vue.use(Router);

/* Layout   */

import Layout from "@/layout";

/**
 * Note: 路由配置项
 *
 * hidden: true                     // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true                 // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                  // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                  // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                  // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect             // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'               // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
 * meta : {
    noCache: true                   // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'                  // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'                // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false               // 如果设置为false，则不会在breadcrumb面包屑中显示
    activeMenu: '/system/user'      // 当路由设置了该属性，则会高亮相对应的侧边栏。
  }
 */
//  前台静态
export let constantBmRoutes = [
  // 沟通
  {
    path: "/Bm-messageCenter",
    component: Layout,
    hidden: true,
    meta: {
      title: "沟通",
      index: 0
    },
    children: [
      {
        meta: {
          title: "沟通",
          id: 1,
          icon: "zx_icon_nor",
          icon2: "zx_icon_sel"
        },
        path: "messageCenter",
        component: resolve =>require(["@/BMViews/views/userCenter/messageCenter/index.vue"], resolve),
      },
    ]
  },
  // 圈子
  {
    path: '/Bm-myAskAround',
    component: Layout,
    hidden: true,
    meta: {
      title: '圈子'
    },
    children: [
      {
        meta: {
          title: '圈子',
          icon: "qz_icon_nor",
          icon2: "qz_icon_sel"
        },
        path: 'index',
        component: (resolve) => require(['@/BMViews/views/myAskAround/index.vue'], resolve)
      }
    ]
  },
  
  // 合同
  // {
  //   path: '/Bm-contract',
  //   component: Layout,
  //   hidden: true,
  //   meta: {
  //     title: '合同',

  //   },
  //   children: [

  //     {
  //       meta: {
  //         icon: "htzx_icon_nor",
  //         icon2: 'htzx_icon_sel',
  //         title: '咨询',
  //         mid: 2,
  //       },
  //       path: 'contractConsult',

  //       component: (resolve) => require(['@/BMViews/views/Consult/finance/index.vue'], resolve)
  //     },
  //   ]
  // },
  // 咨询
  {
    path: "/Bm-Consult",
    // layout是父路由
    component: Layout,
    // 是否隐藏
    hidden: true,
    meta: {
      // 一级菜单的名字
      title: "咨询"
    },
    children: [
      {
        meta: {
          //二级菜单的图标 icon是不高亮
          icon: "cai_icon_nor",
          //二级菜单的图标 icon2是高亮
          icon2: "cai_icon_sel",
          // 二级菜单的名字
          title: "财务服务",
          // 二级菜单的id
          id: 1
        },
        // 二级菜单的跳转地址
        path: "finance",
        // 二级菜单的文件地址
        component: resolve =>
          require(["@/BMViews/views/Consult/finance/index.vue"], resolve)
      },
      {
        meta: {
          // 二级菜单的名字
          title: "法务服务",
          //二级菜单的图标 icon2是高亮
          icon: "fa_icon_nor",
          //二级菜单的图标 icon2是高亮
          icon2: "fa_icon_sel",
          // 二级菜单的id
          id: 2
        },
        path: "legalAffairs",
        component: resolve =>
          require(["@/BMViews/views/Consult/finance/index.vue"], resolve)
      },
      {
        meta: {
          title: "税务服务",
          icon: "sui_icon_nor",
          icon2: "sui_icon_sel",
          id: 3
        },
        path: "taxation",
        component: resolve =>
          require(["@/BMViews/views/Consult/finance/index.vue"], resolve)
      },
      {
        meta: {
          title: "商业服务",
          icon: "sui_icon_nor",
          icon2: "sui_icon_sel",
          id: 4
        },
        path: "business",
        component: resolve =>
          require(["@/BMViews/views/Consult/finance/index.vue"], resolve)
      },
      {
        meta: {
          title: "境外电商",
          icon: "sui_icon_nor",
          icon2: "sui_icon_sel",
          id: 5
        },
        path: "foreignElectricity",
        component: resolve =>
          require(["@/BMViews/views/Consult/finance/index.vue"], resolve)
      }
    ]
  },
  
  
  // 工具
  {
    path: "/Bm-tool",
    component: Layout,
    hidden: true,
    meta: {
      title: "工具"
    },
    children: [
      // {
      //   meta: {
      //     // icon: "ssmn_icon_sel(1)",
      //     // icon2: 'ssmn_icon_sel',
      //     title: '诉讼模拟',
      //     id: 2,
      //   },
      //   path: 'simulation',
      //   component: (resolve) => require(['@/BMViews/views/tool/contractAudit/index.vue'], resolve)
      // },
      {
        meta: {
          icon: "cd_icon_nor",
          icon2: 'cd_icon_sel',
          title: "导航",
          id: 1
        },
        path: "index",
        component: resolve =>
          require(["@/BMViews/views/tool/index.vue"], resolve)
      },
      {
        meta: {
          icon: "fpwt_icon_nor",
          icon2: 'fpwt_icon_sel',
          title: "秒贷",
          id: 2
        },
        path: "Loans",
        component: resolve =>
          require(["@/BMViews/views/tool/loans/index.vue"], resolve)
      },
      {
        meta: {
          title: "阿米巴预算",
          id: 2
        },
        path: "budget",
        component: resolve =>
          require(["@/BMViews/views/tool/budget/index.vue"], resolve)
      }
    ]
  },
  // 合同
  {
    path: "/Bm-contract",
    component: Layout,
    hidden: true,
    meta: {
      title: "合同"
    },
    children: [
      {
        meta: {
          title: "合同模板",
          id: 1
        },
        path: "contract",
        component: resolve =>
          require(["@/BMViews/views/Contract/contractTmp/index.vue"], resolve)
      },
      {
        meta: {
          title: "合同智审",
          id: 2
        },
        path: "review",
        component: resolve =>
          require(["@/BMViews/views/tool/contractAudit/index.vue"], resolve)
      },
      // {
      //   meta: {
      //     title: "合同咨询",
      //     id: 3,
      //   },
      //   path: "/Bm-Consult/1547940371877711872",
      //   // parentPath: "/Bm-Consult",
      //   component: () => import("@/BMViews/views/Consult/finance/index.vue"),
      // },
      {
        meta: {
          title: "智慧文控",
          id: 4
        },
        path: "IntelligentControl",
        component: resolve =>
          require([
            "@/BMViews/views/tool/IntelligentControl/index.vue"
          ], resolve)
      }
    ]
  },

  // 项目
  {
    path: "/Bm-project",
    component: Layout,
    hidden: true,
    meta: {
      title: "项目",
    },
    children: [
      {
        meta: {
          icon: "cai_icon_nor",
          icon2: "cai_icon_sel",
          title: "产业园区",
          id: 1,
        },
        path: "finance",
        component: (resolve) =>
          require(["@/BMViews/views/project/index.vue"], resolve),
      },
      {
        meta: {
          icon: "fa_icon_nor",
          icon2: "fa_icon_sel",
          title: "金融服务",
          id: 2,
        },
        path: "legalAffairs",
        component: (resolve) =>
          require(["@/BMViews/views/project/index.vue"], resolve),
      },
      {
        meta: {
          icon: "fa_icon_nor",
          icon2: "fa_icon_sel",
          title: "资格资质",
          id: 3,
        },
        path: "taxation",
        component: (resolve) =>
          require(["@/BMViews/views/project/index.vue"], resolve),
      },
    ],
  },
  
  // 搜搜
  {
    path: "/Bm-search",
    component: Layout,
    hidden: true,
    meta: {
      title: "搜搜",
      index: 0
    },
    children: [
      {
        meta: {
          title: "解答",
          id: 2,
          icon: "jieda_icon_nor",
          icon2: "jieda_icon_sel"
        },
        path: "searchAnswer",
        component: resolve =>
          require(["@/BMViews/views/Search/searchAnswer/index.vue"], resolve)
      },
      {
        meta: {
          title: "咨询",
          id: 5,
          icon: "soso-top",
          icon2: "zc_icon_sel"
        },
        path: "searchPolicy",
        component: resolve =>
          require(["@/BMViews/views/Search/searchAnswer/index.vue"], resolve)
      },
      {
        meta: {
          icon: "ft_icon_nor",
          icon2: "ft_icon_sel",

          title: "工具",
          id: 6
        },
        path: "searchLaw",
        component: resolve =>
          require(["@/BMViews/views/Search/searchAnswer/index.vue"], resolve)
      },
      // {
      //   meta: {
      //     title: "政策",
      //     id: 3,
      //     icon: "soso-top",
      //     icon2: "zc_icon_sel"
      //   },
      //   path: "searchPolicy",
      //   component: resolve =>
      //     require(["@/BMViews/views/Search/searchAnswer/index.vue"], resolve)
      // },
      // {
      //   meta: {
      //     icon: "ft_icon_nor",
      //     icon2: "ft_icon_sel",

      //     title: "法条",
      //     id: 1
      //   },
      //   path: "searchLaw",
      //   component: resolve =>
      //     require(["@/BMViews/views/Search/searchAnswer/index.vue"], resolve)
      // },
      {
        meta: {
          title: "合同",
          id: 4,
          icon: "ht_icon_nor",
          icon2: "ht_icon_sel"
        },
        path: "searchContract",
        component: resolve =>
          require(["@/BMViews/views/Search/searchAnswer/index.vue"], resolve)
      }
    ]
  },
  // 帮助
  {
    path: "/Bm-help",
    component: Layout,
    hidden: true,
    meta: {
      title: "帮助"
    },
    children: [
      {
        meta: {
          icon: "zhwt_icon_nor",
          icon2: "zhwt_icon_sel",
          title: "账户",
          id: 1,
          name: "账号问题"
        },
        path: "accountProblem",
        component: resolve =>
          require([
            "@/BMViews/views/helpCenter/accountProblem/index.vue"
          ], resolve)
      },
      {
        meta: {
          icon: "gmwt_icon_nor",
          icon2: "gmwt_icon_sel",
          title: "购买",
          id: 2,
          name: "购买问题"
        },
        path: "buyProblem",
        // component: (resolve) => require(['@/BMViews/views/helpCenter/buyProblem/index.vue'], resolve)
        component: resolve =>
          require([
            "@/BMViews/views/helpCenter/accountProblem/index.vue"
          ], resolve)
      },
      {
        meta: {
          icon: "fpwt_icon_nor",
          icon2: "fpwt_icon_sel",
          title: "发票",
          id: 3,
          name: "发票问题"
        },
        path: "invoiceIssue",
        // component: (resolve) => require(['@/BMViews/views/helpCenter/invoiceIssue/index.vue'], resolve)
        component: resolve =>
          require([
            "@/BMViews/views/helpCenter/accountProblem/index.vue"
          ], resolve)
      },
      {
        meta: {
          title: "使用",
          icon: "sywt_icon_nor",
          icon2: "sywt_icon_sel",
          name: "使用问题",
          id: 4
        },
        path: "usageProblem",
        // component: (resolve) => require(['@/BMViews/views/helpCenter/usageProblem/index.vue'], resolve)
        component: resolve =>
          require([
            "@/BMViews/views/helpCenter/accountProblem/index.vue"
          ], resolve)
      }
    ]
  }
  // 更多
  // {
  //   path: '/Bm-more',
  //   component: Layout,
  //   hidden: true,
  //   meta: {
  //     // title: 'ge'
  //     icon: "android_icon"
  //   },
  //   children: [
  //     {
  //       meta: {
  //         title: '账户问题'
  //       },
  //       path: 'accountProblem',
  //       component: (resolve) => require(['@/BMViews/views/helpCenter/accountProblem/index.vue'], resolve)
  //     }
  //     ,
  //     {
  //       meta: {
  //         title: '购买问题'
  //       },
  //       path: 'buyProblem',
  //       component: (resolve) => require(['@/BMViews/views/helpCenter/buyProblem/index.vue'], resolve)
  //     }
  //     ,
  //     {
  //       meta: {
  //         title: '发票问题'
  //       },
  //       path: 'invoiceIssue',
  //       component: (resolve) => require(['@/BMViews/views/helpCenter/invoiceIssue/index.vue'], resolve)
  //     }
  //     ,
  //     {
  //       meta: {
  //         title: '使用问题',

  //       },
  //       path: 'usageProblem',
  //       component: (resolve) => require(['@/BMViews/views/helpCenter/usageProblem/index.vue'], resolve)
  //     }
  //   ]
  // },
];

//个人中心
const personalCenter = [
  {
    path: "/Bm-personalCenter",
    component: Layout,
    hidden: true,
    meta: {
      title: "帮助1"
      // icon: "personalCenter"
    },
    children: [
      {
        meta: {
          title: "我的主页"
        },
        path: "homepage",
        component: resolve =>
          require(["@/BMViews/views/userCenter/homepage/index.vue"], resolve)
      },
      {
        meta: {
          title: "专家认证"
        },
        path: "expertsCert",
        component: resolve =>
          require(["@/BMViews/views/userCenter/expertsCert/index.vue"], resolve)
      },
      {
        meta: {
          title: "我的圈子"
        },
        path: "myAskAround",
        component: resolve =>
          require(["@/BMViews/views/myAskAround/index.vue"], resolve)
      },
      {
        meta: {
          title: "我的订单"
        },
        path: "myOrder",
        component: resolve =>
          require(["@/BMViews/views/userCenter/myOrder/index.vue"], resolve)
      },
      {
        meta: {
          title: "购买问题"
        },
        path: "buyProblem",
        component: resolve =>
          require(["@/BMViews/views/helpCenter/buyProblem/index.vue"], resolve)
      },
      {
        meta: {
          title: "我的圈子"
        },
        path: "myAskAround",
        component: resolve =>
          require(["@/BMViews/views/myAskAround/index.vue"], resolve)
      },
      {
        meta: {
          title: "发票问题"
        },
        path: "invoiceIssue",
        component: resolve =>
          require([
            "@/BMViews/views/helpCenter/invoiceIssue/index.vue"
          ], resolve)
      },
      {
        meta: {
          title: "使用问题"
        },
        path: "usageProblem",
        component: resolve =>
          require([
            "@/BMViews/views/helpCenter/usageProblem/index.vue"
          ], resolve)
      },
      {
        meta: {
          title: "关于发票"
        },
        path: "aboutInvoice",
        component: resolve =>
          require([
            "@/BMViews/views/userCenter/aboutInvoice/index.vue"
          ], resolve)
      },
      {
        meta: {
          title: "消息中心"
        },
        path: "messageCenter",
        component: resolve =>
          require([
            "@/BMViews/views/userCenter/messageCenter/index.vue"
          ], resolve)
      },
      {
        meta: {
          title: "关于问三师"
        },
        path: "aboutUs",
        component: resolve =>
          require(["@/BMViews/views/userCenter/aboutUs/index.vue"], resolve)
      },
      {
        meta: {
          title: "学习"
        },
        path: "study",
        component: resolve =>
          require(["@/BMViews/views/userCenter/study/index.vue"], resolve)
      },
      {
        meta: {
          title: "登录"
        },
        path: "login",
        component: resolve =>
          require(["@/BMViews/views/userCenter/login/index.vue"], resolve)
      },
      //个人中心
      {
        path: "userSetting",
        component: resolve => require(["@/BMViews/views/userSetting"], resolve),
        hidden: true
      },
      // 行知历
      {
        meta: {
          title: "行知历"
        },
        path: "knownAction",
        component: resolve =>
          require(["@/BMViews/views/knownAction/index.vue"], resolve)
      }
    ]
  },

  {
    path: "",
    component: Layout,
    redirect: getToken()
      ? "/Bm-tool/budget"
      : "/Bm-personalCenter/login",
    children: [
      {
        path: "index",
        // component: (resolve) => require(['@/views/index'], resolve),
        component: resolve =>
          require(["@/wss/views/welcome/index.vue"], resolve),
        name: "Index",
        meta: { title: "工作日历", icon: "dashboard", affix: true }
      }
    ]
  }
];

// 后台-公共路由
export const constantRoutes = [
  {
    path: "/redirect",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/redirect/:path(.*)",
        component: resolve => require(["@/views/redirect"], resolve)
      }
    ]
  },
  {
    path: "/login",
    // component: (resolve) => require(['@/BMViews/views/userCenter/login/index.vue'], resolve),
    component: resolve => require(["@/views/login"], resolve)
    // hidden: true

    // component: Layout,
    // redirect: '/login/index',
    // children: [
    //   {
    //     path: 'index',
    //     // component: (resolve) => require(['@/views/index'], resolve),
    //     component: (resolve) => require(['@/wss/views/welcome/index.vue'], resolve),
    //     name: 'Index',
    //     meta: { title: '工作日历', icon: 'dashboard', affix: true }
    //   }
    // ]
  },
  {
    path: "/register",
    component: resolve => require(["@/views/register"], resolve),
    hidden: true
  },
  // {
  //   path: '/404',
  //   component: (resolve) => require(['@/views/error/404'], resolve),
  //   hidden: true
  // },
  {
    path: "/user",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "profile",
        component: resolve =>
          require(["@/views/system/user/profile/index"], resolve),
        name: "Profile",
        meta: { title: "个人中心", icon: "user" }
      }
    ]
  },
  {
    path: "/system/user-auth",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "role/:userId(/d+)",
        component: resolve =>
          require(["@/wss/views/systems/user/authRole"], resolve),
        name: "AuthRole",
        meta: { title: "分配角色", activeMenu: "/system/user" }
      }
    ]
  },
  {
    path: "/system/role-auth",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "user/:roleId(\\d+)",
        component: resolve =>
          require(["@/wss/views/systems/role/authUser.vue"], resolve),
        name: "AuthUser",
        meta: { title: "分配用户", activeMenu: "/system/role" }
      }
    ]
  },
  {
    path: "/system/dict-data",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "index/:dictId(\\d+)",
        component: resolve => require(["@/views/system/dict/data"], resolve),
        name: "Data",
        meta: { title: "字典数据", activeMenu: "/system/dict" }
      }
    ]
  },
  {
    path: "/monitor/job-log",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "index",
        component: resolve => require(["@/views/monitor/job/log"], resolve),
        name: "JobLog",
        meta: { title: "调度日志", activeMenu: "/monitor/job" }
      }
    ]
  },
  {
    path: "/tool/gen-edit",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "index",
        component: resolve => require(["@/views/tool/gen/editTable"], resolve),
        name: "GenEdit",
        meta: { title: "修改生成配置", activeMenu: "/tool/gen" }
      }
    ]
  },
  //图片文件夹详情
  {
    path: "/contentSupervision/pictureManagement",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "pictureManagement-classificationManagement",
        component: resolve =>
          require([
            "@/wss/views/contentSupervision/pictureManagement/classificationManagement.vue"
          ], resolve),
        name: "pictureManagement-classificationManagement",
        meta: {
          title: "",
          activeMenu: "/pictureManagement/classificationManagement"
        }
      }
    ]
  },
  //员工工资详细
  {
    path: "/fnancialPlatform/accountingManagemen",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "salaryDetails",
        component: resolve =>
          require([
            "@/wss/views/fnancialPlatform/accountingManagement/salaryDetails.vue"
          ], resolve),
        name: "salaryDetails",
        meta: {
          title: "工资明细",
          activeMenu: "/fnancialPlatform/accountingManagement"
        }
      }
    ]
  },
  //kpi设定
  {
    path: "/humanResourcesPlatform/performanceRules",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "KPISetting",
        component: resolve =>
          require([
            "@/wss/views/humanResourcesPlatform/performanceRules/KPISetting.vue"
          ], resolve),
        name: "KPISetting",
        meta: {
          title: "KPI设定",
          activeMenu: "/humanResourcesPlatform/performanceRules"
        }
      }
    ]
  },
  //专家个人信息
  {
    path: "/consult/exper/expertList",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "expertInfo",
        component: resolve =>
          require([
            "@/wss/views/consult/exper/expertList/expertInfo.vue"
          ], resolve),
        name: "expertInfo",
        meta: {
          title: "专家个人信息",
          activeMenu: "/consult/exper/expertList"
        }
      }
    ]
  },
  {
    path: "/contract",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "list",
        component: resolve =>
          require(["@/wss/views/workbench/contract/list/index.vue"], resolve),
        name: "contractList",
        meta: { title: "专家个人信息" }
      }
    ]
  }
];

// 邀请用户
let inviteArr = [
  {
    path: "/wssregister",

    hidden: true,

    component: resolve => require(["@/BMViews/invite/register.vue"], resolve)
  },
  {
    path: "/registerSucceed",

    hidden: true,

    component: resolve =>
      require(["@/BMViews/invite/registerSucceed.vue"], resolve)
  },
  {
    path: "/wssagreement",

    hidden: true,

    component: resolve => require(["@/BMViews/invite/agreement.vue"], resolve)
  }
];

// 动态渲染项目和咨询的分类
export async function getTypeListFn() {
  const service = axios.create({
    baseURL: process.env.VUE_APP_BASE_API,
    timeout: 30000
  });
  // --------------*********************咨询类型--------------*********************
  let { data: consult } = await service({
    url: `/work/consultType/findConsultTypeList`,
    method: "get"
  });
  if (consult.code != 200) return;
  const consultList = consult.rows;
  // 获取下标
  let consultIndex = constantBmRoutes.findIndex(
    item => item.path == "/Bm-Consult"
  );
  constantBmRoutes[consultIndex].children = [];
  consultList.forEach(item => {
    constantBmRoutes[consultIndex].children.push({
      meta: {
        icon: "cai_icon_nor",
        icon2: "cai_icon_sel",
        title: item.name,
        id: item.id
      },
      path: "/Bm-Consult/" + item.id,
      parentPath: "/Bm-Consult",
      component: () => import("@/BMViews/views/Consult/finance/index.vue")
    });
  });
  // --------------*********************咨询类型--------------*********************end

  // --------------*********************项目类型--------------*********************
  let { data: project } = await service({
    url: `/work/projectType/findProjectTypeList`,
    method: "get",
  });
  if (project.code != 200) return;
  const projectList = project.rows; //所有项目的类别

  // 获取下标
  let projectIndex = constantBmRoutes.findIndex(
    (item) => item.path == "/Bm-project"
  );
  constantBmRoutes[projectIndex].children = [];
  projectList.forEach((item) => {
    constantBmRoutes[projectIndex].children.push({
      meta: {
        icon: "cai_icon_nor",
        icon2: "cai_icon_sel",
        title: item.name,
        id: item.id,
      },
      path: "/Bm-project/" + item.id,
      parentPath: "/Bm-project",
      component: () => import("@/BMViews/views/project/index.vue"),
    });
  });
  // --------------*********************项目类型--------------*********************end

  // --------------*********************帮助设置--------------*********************
  let { data: help } = await service({
    url: `/doc/helps/list`,
    method: "get"
  });
  if (help.code != 200) return;
  // 过滤出所有的帮助设置type
  let helpTypeList = helpType(help.data.rows);
  // // 获取帮助设置在路由里面的下标
  let helpIndex = constantBmRoutes.findIndex(item => item.path == "/Bm-help");

  constantBmRoutes[helpIndex].children = [];
  helpTypeList.forEach(item => {
    constantBmRoutes[helpIndex].children.push({
      meta: {
        icon: "cai_icon_nor",
        icon2: "cai_icon_sel",
        title: item.type,
        typeId: item.typeId
      },
      path: "/Bm-help/" + item.typeId,
      parentPath: "/Bm-help",
      component: () =>
        import("@/BMViews/views/helpCenter/accountProblem/index.vue")
    });
  });
  // 帮助添加系统下载的链接
  constantBmRoutes[helpIndex].children.push({
    meta: {
      title: "系统下载"
    },
    path: "aboutUs",
    component: () => import("@/BMViews/views/userCenter/aboutUs/index.vue")
  });
  // --------------*********************帮助设置--------------*********************end

  // 动态添加404页面
  constantRoutes.push({
    path: "/404",
    component: () => import("@/views/error/404"),
    hidden: true
  });

  // 把路由重新放进去 constantBmRoutes前台路由 constantRoutes公共路由 personalCenter个人中心 inviteArr邀请新用户
  temp = [
    ...constantBmRoutes,
    ...constantRoutes,
    ...personalCenter,
    ...inviteArr
  ];
  // localStorage.setItem('routeList',JSON.stringify(temp))
  router.addRoutes(temp);
}

// constantBmRoutes前台路由 constantRoutes公共路由 personalCenter个人中心 inviteArr邀请新用户
let temp = [
  ...constantBmRoutes,
  ...constantRoutes,
  ...personalCenter,
  ...inviteArr
];

getTypeListFn();
let router = new Router({
  mode: "history", // 去掉url中的#
  scrollBehavior: () => ({ y: 0 }),
  routes: temp
});

export default router;
